//package com.duobaoyu.dby.supply.biz.client.boundary.refund;
//
//import com.duobaoyu.dby.channel.adapter.bean.refund.AfterSaleOrderInfo;
//import com.duobaoyu.dby.channel.adapter.enums.biz.refund.AfterSaleTypeEnum;
//import com.duobaoyu.dby.channel.boundary.bean.refund.param.AfterSaleAttributesParam;
//import com.duobaoyu.dby.channel.boundary.bean.refund.param.AfterSaleVoucherParam;
//import com.duobaoyu.dby.channel.boundary.bean.refund.result.*;
//import com.duobaoyu.dby.common.mybatis.config.IdGeneratorSnowflake;
//import com.duobaoyu.dby.supply.biz.client.boundary.order.bean.bo.OrderBO;
//import com.duobaoyu.dby.supply.biz.client.boundary.order.bean.bo.OrderProductBO;
//import com.duobaoyu.dby.supply.biz.client.boundary.refund.bo.AfterSaleLogisticsBO;
//import com.duobaoyu.dby.supply.common.biz.bo.refund.AfterSaleOutBO;
//import com.duobaoyu.dby.supply.common.biz.bo.refund.AfterSalePickUpBO;
//import com.duobaoyu.dby.supply.common.biz.bo.refund.AfterSaleReturnShipmentBO;
//import com.duobaoyu.dby.supply.common.biz.bo.refund.AfterSaleWayBillInBO;
//import com.duobaoyu.dby.supply.common.biz.bo.refund.client.AfterSaleApplyClientOutBO;
//import com.google.common.collect.Lists;
//import lombok.RequiredArgsConstructor;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalDateTime;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * Created by shuming on 2023/10/27 14:39
// */
////@Primary
//@Service
//@RequiredArgsConstructor
//public class AfterSaleBoundaryMockClient implements AfterSaleBoundaryClient {
//
//    private final IdGeneratorSnowflake idGeneratorSnowflake;
//
//    @Override
//    public AfterSaleLogisticsBO queryAfterSaleLogistics(String channelCode, String afterSaleSn, String channelOrderSn) {
//        return null;
//    }
//
//    @Override
//    public RefundCancelResult cancelOrder(AfterSaleOutBO afterSale, String cancelRemark) {
//        RefundCancelResult result = new RefundCancelResult();
//        result.setSuccess(true);
//        return result;
//    }
//
//    @Override
//    public AfterSaleConfirmResult confirmAfterSale(AfterSaleOutBO afterSale) {
//
//        AfterSaleConfirmResult result = new AfterSaleConfirmResult();
//        result.setResult(true);
//        return result;
//    }
//
//    @Override
//    public AfterSaleRefundDetailResult jdVopAfterSaleRefundDetail(AfterSaleOutBO afterSale) {
//
//        AfterSaleRefundDetailResult result = new AfterSaleRefundDetailResult();
//        result.setAfterSaleTradeSn(afterSale.getAfterSaleTradeOrderSn());
//        result.setChannelAfterSaleSn(afterSale.getChannelAfterSaleSn());
//        result.setChannelOrderSn(afterSale.getChannelOrderSn());
//        result.setChannelRefundAmount(afterSale.getApplyRefundAmount());
//        result.setChannelOriginalOrderSn(afterSale.getChannelOrderSn());
//        result.setModifyDate(LocalDateTime.now());
//        List<AfterSaleRefundDetailResult.Item> items = afterSale.getItems().stream().map(e -> {
//            AfterSaleRefundDetailResult.Item item = new AfterSaleRefundDetailResult.Item();
//            item.setProductNumber(e.getApplyNum());
//            item.setChannelSkuCode(e.getChannelSkuCode());
//            item.setChannelSkuName(e.getSkuName());
//            return item;
//        }).collect(Collectors.toList());
//        result.setChannelRefundProducts(items);
//        return result;
//    }
//
//    @Override
//    public List<AfterSaleAttributesResult> queryAfterSaleReason(OrderBO order, List<OrderProductBO> orderProducts) {
//
//        List<AfterSaleAttributesResult.Attribute> attributes = orderProducts.stream().map(e -> {
//            AfterSaleAttributesResult.Attribute attribute = new AfterSaleAttributesResult.Attribute();
//            attribute.setChannelCode(order.getChannelCode());
//            attribute.setOrderTradeSn(order.getOrderTradeSn());
//            attribute.setChannelOrderSn(order.getChannelOrderSn());
//            attribute.setPermitRetNum(e.getSkuNum());
//            attribute.setPermitChgNum(e.getSkuNum());
//            attribute.setChannelSkuCode(e.getChannelSkuCode());
//            attribute.setSkuCode(e.getSkuCode());
//            attribute.setPickUpWays(null);
//
//            AfterSaleAttributesResult.AfterSaleReason returnReason = new AfterSaleAttributesResult.AfterSaleReason();
//            returnReason.setAfterSaleType(AfterSaleTypeEnum.RETURNED);
//            AfterSaleAttributesResult.ReasonDetail returnReasonDetail = new AfterSaleAttributesResult.ReasonDetail();
//            returnReasonDetail.setChannelAfterSaleReasonCode("100");
//            returnReasonDetail.setChannelAfterSaleReason("不想要了");
//            returnReasonDetail.setNoRefundCarriage(false);
//            returnReasonDetail.setNeedVoucher(false);
//            returnReasonDetail.setNeedRefundDesc(false);
//            returnReason.setReasonDetails(Lists.newArrayList(returnReasonDetail));
//
//            AfterSaleAttributesResult.AfterSaleReason exchangeReason = new AfterSaleAttributesResult.AfterSaleReason();
//            exchangeReason.setAfterSaleType(AfterSaleTypeEnum.RETURNED);
//            AfterSaleAttributesResult.ReasonDetail exchangeReasonDetail = new AfterSaleAttributesResult.ReasonDetail();
//            exchangeReasonDetail.setChannelAfterSaleReasonCode("101");
//            exchangeReasonDetail.setChannelAfterSaleReason("7天无理由退货");
//            exchangeReasonDetail.setNoRefundCarriage(false);
//            exchangeReasonDetail.setNeedVoucher(false);
//            exchangeReasonDetail.setNeedRefundDesc(false);
//            exchangeReason.setReasonDetails(Lists.newArrayList(exchangeReasonDetail));
//            attribute.setAfterSaleReasons(Lists.newArrayList(returnReason, exchangeReason));
//            attribute.setAfterSaleTypes(attribute.getAfterSaleReasons().stream()
//                    .map(t -> t.getAfterSaleType().getValue()).collect(Collectors.toList()));
//            return attribute;
//        }).collect(Collectors.toList());
//
//        AfterSaleAttributesResult result = new AfterSaleAttributesResult();
//        result.setAttributes(attributes);
//        result.setSuccess(true);
//        return Lists.newArrayList(result);
//    }
//
//    @Override
//    public List<AfterSaleReturnAddressResult> afterSaleAddressQuery(List<AfterSaleOutBO> afterSales) {
//        return null;
//    }
//
//    @Override
//    public List<AfterSaleAttributesResult> afterSaleAttributesQuery(List<AfterSaleAttributesParam> params) {
//        return null;
//    }
//
//    @Override
//    public AfterSaleWayBillResult backFillWaybill(AfterSaleOutBO item, AfterSaleWayBillInBO waybill) {
//
//        AfterSaleWayBillResult result = new AfterSaleWayBillResult();
//        result.setResult(true);
//        return result;
//    }
//
//    @Override
//    public AfterSaleVoucherResult afterSaleVoucher(AfterSaleVoucherParam param) {
//        return null;
//    }
//
//    @Override
//    public AfterSaleParticularResult queryAfterSale(AfterSaleOutBO afterSale) {
//
//        AfterSaleParticularResult result = new AfterSaleParticularResult();
//        result.setAfterSaleTradeSn(afterSale.getAfterSaleSn());
//        result.setAfterSaleSn(afterSale.getAfterSaleSn());
//        result.setChannelAfterSaleSn(afterSale.getChannelAfterSaleSn());
//
//        AfterSaleOrderInfo afterSaleOrderInfo = new AfterSaleOrderInfo();
//        afterSaleOrderInfo.setChannelOrderSn(afterSale.getChannelOrderSn());
//        afterSaleOrderInfo.setRejectReason("不想要了");
//        afterSaleOrderInfo.setChannelRealRefundAmount(afterSale.getApplyRefundAmount());
//        afterSaleOrderInfo.setAfterSaleStatus(null);
//        afterSaleOrderInfo.setNewPickupType(0);
//        afterSaleOrderInfo.setChannelFreightRefundAmount(afterSale.getFreightApplyRefundAmount());
//        result.setAfterSaleOrderInfo(afterSaleOrderInfo);
//        return result;
//    }
//
//    @Override
//    public AfterSaleApplyClientOutBO cancelOrder(AfterSaleOutBO afterSale) {
//        AfterSaleApplyClientOutBO result = new AfterSaleApplyClientOutBO();
//        result.setChannelAfterSaleTradeSn(afterSale.getAfterSaleTradeOrderSn());
//        result.setChannelAfterSaleSn(String.valueOf(idGeneratorSnowflake.snowflakeId()));
//        result.setApplyResult(true);
//        return result;
//    }
//
//    @Override
//    public AfterSaleApplyClientOutBO applyAfterSale(AfterSaleOutBO afterSale,
//                                                    AfterSalePickUpBO afterSalePickUp,
//                                                    AfterSaleReturnShipmentBO returnShipment) {
//        AfterSaleApplyClientOutBO result = new AfterSaleApplyClientOutBO();
//        result.setChannelAfterSaleTradeSn(afterSale.getAfterSaleTradeOrderSn());
//        result.setChannelAfterSaleSn(String.valueOf(idGeneratorSnowflake.snowflakeId()));
//        result.setApplyResult(true);
//        return result;
//    }
//}
